<template>
	<view class="container" style="display: flex;flex-direction: column;padding-bottom: 120rpx;">
		<view style="display: flex;gap: 50rpx;">
			<view style="flex: 1;" class="left">
				<view style="display: flex;gap: 20rpx;flex-direction: column;">
					<view style="flex: 1;display: flex;gap: 20rpx;align-items: center;font-size: 12rpx;">
						<span>From1区域</span>
						<uni-data-select
							style="max-width: 200rpx;font-size: 12rpx;"
							:clear="false"
							v-model="fromOneValue1"
							:localdata="fromOneRange1"
							@change="fromOneChange($event, 1)"
						></uni-data-select>
					</view>
					<view style="flex: 1;display: flex;gap: 20rpx;align-items: center;font-size: 12rpx;">
						<span>From1线体</span>
						<uni-data-select
							style="max-width: 200rpx;font-size: 12rpx;"
							:clear="false"
							v-model="fromOneValue2"
							:localdata="fromOneRange2"
							@change="fromOneChange($event, 2)"
						></uni-data-select>
					</view>
					<view style="flex: 1;display: flex;gap: 20rpx;align-items: center;font-size: 12rpx;">
						<span>From1站点</span>
						<uni-data-select
							style="max-width: 200rpx;font-size: 12rpx;"
							:clear="false"
							v-model="fromOneValue3"
							:localdata="fromOneRange3"
							@change="fromOneChange($event, 3)"
						></uni-data-select>
					</view>
					<view style="flex: 1;display: flex;gap: 20rpx;align-items: center;font-size: 12rpx;">
						<span style="white-space: nowrap;">From1储位</span>
						<view style="position: relative;max-width: 200rpx;flex: 1;">
							<u--input
								placeholder="请扫描或选择"
								v-model="fromOneValue4"
								@blur="blurInput('from1')"
								@focus="focusInput('from1')"
								@confirm="confirmInput('from1')"
								clearable
								@clear="clearInput(1)"
							>
							</u--input>
							<view v-if="visible1" style="width: 100%;position: absolute; overflow-y: scroll;max-height: 360rpx;border: 1rpx solid #dadbde;background-color: #fff;z-index: 999;border-radius: 10rpx;box-sizing: border-box;padding: 15rpx 0;">
								<view v-for="(item, index) in fromOneRange4"
									:key="index"
									class="people-item"
									@click="clickItem('from1', item)"
								>
									{{ item.text }}
								</view>
							</view>
						</view>
					</view>
					<text style="font-size: 14rpx;" :style="{ color: description1  ? '#000' : '#fff' }">
						{{ description1 ? description1 : description3 }}
					</text>
					<!-- ---------------------------------------------------------------------- -->
					<view style="flex: 1;display: flex;gap: 20rpx;align-items: center;font-size: 12rpx;margin-top: 50rpx;">
						<span>From2区域</span>
						<uni-data-select
							style="max-width: 200rpx;font-size: 12rpx;"
							:clear="false"
							v-model="fromTwoValue1"
							:localdata="fromTwoRange1"
							@change="fromTwoChange($event, 1)"
						></uni-data-select>
					</view>
					<view style="flex: 1;display: flex;gap: 20rpx;align-items: center;font-size: 12rpx;">
						<span>From2线体</span>
						<uni-data-select
							style="max-width: 200rpx;font-size: 12rpx;"
							:clear="false"
							v-model="fromTwoValue2"
							:localdata="fromTwoRange2"
							@change="fromTwoChange($event, 2)"
						></uni-data-select>
					</view>
					<view style="flex: 1;display: flex;gap: 20rpx;align-items: center;font-size: 12rpx;">
						<span>From2站点</span>
						<uni-data-select
							style="max-width: 200rpx;font-size: 12rpx;"
							:clear="false"
							v-model="fromTwoValue3"
							:localdata="fromTwoRange3"
							@change="fromTwoChange($event, 3)"
						></uni-data-select>
					</view>
					<view style="flex: 1;display: flex;gap: 20rpx;align-items: center;font-size: 12rpx;">
						<span style="white-space: nowrap;">From2储位</span>
						<view style="position: relative;max-width: 200rpx;flex: 1;">
							<u--input
								placeholder="请扫描或选择"
								v-model="fromTwoValue4"
								@blur="blurInput('from2')"
								@focus="focusInput('from2')"
								@confirm="confirmInput('from2')"
								clearable
								@clear="clearInput(2)"
							>
							</u--input>
							<view v-if="visible2" style="width: 100%;position: absolute; overflow-y: scroll;max-height: 360rpx;border: 1rpx solid #dadbde;background-color: #fff;z-index: 999;border-radius: 10rpx;box-sizing: border-box;padding: 15rpx 0;">
								<view v-for="(item, index) in fromTwoRange4"
									:key="index"
									class="people-item"
									@click="clickItem('from2', item)"
								>
									{{ item.text }}
								</view>
							</view>
						</view>
					</view>
					<text style="font-size: 14rpx;">
						{{ description2 }}
					</text>
				</view>
			</view>
			<view style="flex: 1;" class="right">
				<view style="display: flex;gap: 20rpx;flex-direction: column;">
					<view style="flex: 1;display: flex;gap: 20rpx;align-items: center;font-size: 12rpx;">
						<span>TO1区域</span>
						<uni-data-select
							style="max-width: 200rpx;font-size: 12rpx;"
							:clear="false"
							v-model="toOneValue1"
							:localdata="toOneRange1"
							@change="toOneChange($event, 1)"
						></uni-data-select>
					</view>
					<view style="flex: 1;display: flex;gap: 20rpx;align-items: center;font-size: 12rpx;">
						<span>TO1线体</span>
						<uni-data-select
							style="max-width: 200rpx;font-size: 12rpx;"
							:clear="false"
							v-model="toOneValue2"
							:localdata="toOneRange2"
							@change="toOneChange($event, 2)"
						></uni-data-select>
					</view>
					<view style="flex: 1;display: flex;gap: 20rpx;align-items: center;font-size: 12rpx;">
						<span>TO1站点</span>
						<uni-data-select
							style="max-width: 200rpx;font-size: 12rpx;"
							:clear="false"
							v-model="toOneValue3"
							:localdata="toOneRange3"
							@change="toOneChange($event, 3)"
						></uni-data-select>
					</view>
					<view style="flex: 1;display: flex;gap: 20rpx;align-items: center;font-size: 12rpx;">
						<span style="white-space: nowrap;">TO1储位</span>
						<view style="position: relative;max-width: 200rpx;flex: 1;">
							<u--input
								placeholder="请扫描或选择"
								v-model="toOneValue4"
								@blur="blurInput('to1')"
								@focus="focusInput('to1')"
								@confirm="confirmInput('to1')"
								clearable
								@clear="clearInput(3)"
							>
							</u--input>
							<view v-if="visible3" style="width: 100%;position: absolute; overflow-y: scroll;max-height: 360rpx;border: 1rpx solid #dadbde;background-color: #fff;z-index: 999;border-radius: 10rpx;box-sizing: border-box;padding: 15rpx 0;">
								<view v-for="(item, index) in toOneRange4"
									:key="index"
									class="people-item"
									@click="clickItem('to1', item)"
								>
									{{ item.text }}
								</view>
							</view>
						</view>
					</view>
					<text style="font-size: 14rpx;" :style="{ color: description3  ? '#000' : '#fff' }">
						{{ description3 ? description3 : description1 }}
					</text>
					<!-- ------------------------------------------------------------------- -->
					<view style="flex: 1;display: flex;gap: 20rpx;align-items: center;font-size: 12rpx;margin-top: 50rpx;">
						<span>TO2区域</span>
						<uni-data-select
							style="max-width: 200rpx;font-size: 12rpx;"
							:clear="false"
							v-model="toTwoValue1"
							:localdata="toTwoRange1"
							@change="toTwoChange($event, 1)"
						></uni-data-select>
					</view>
					<view style="flex: 1;display: flex;gap: 20rpx;align-items: center;font-size: 12rpx;">
						<span>TO2线体</span>
						<uni-data-select
							style="max-width: 200rpx;font-size: 12rpx;"
							:clear="false"
							v-model="toTwoValue2"
							:localdata="toTwoRange2"
							@change="toTwoChange($event, 2)"
						></uni-data-select>
					</view>
					<view style="flex: 1;display: flex;gap: 20rpx;align-items: center;font-size: 12rpx;">
						<span>TO2站点</span>
						<uni-data-select
							style="max-width: 200rpx;font-size: 12rpx;"
							:clear="false"
							v-model="toTwoValue3"
							:localdata="toTwoRange3"
							@change="toTwoChange($event, 3)"
						></uni-data-select>
					</view>
					<view style="flex: 1;display: flex;gap: 20rpx;align-items: center;font-size: 12rpx;">
						<span style="white-space: nowrap;">TO2储位</span>
						<view style="position: relative;max-width: 200rpx;flex: 1;">
							<u--input
								placeholder="请扫描或选择"
								v-model="toTwoValue4"
								@blur="blurInput('to2')"
								@focus="focusInput('to2')"
								@confirm="confirmInput('to2')"
								clearable
								@clear="clearInput(4)"
							>
							</u--input>
							<view v-if="visible4" style="width: 100%;position: absolute; overflow-y: scroll;max-height: 360rpx;border: 1rpx solid #dadbde;background-color: #fff;z-index: 999;border-radius: 10rpx;box-sizing: border-box;padding: 15rpx 0;">
								<view v-for="(item, index) in toTwoRange4"
									:key="index"
									class="people-item"
									@click="clickItem('to2', item)"
								>
									{{ item.text }}
								</view>
							</view>
						</view>
					</view>
					<text style="font-size: 14rpx;">
						{{ description4 }}
					</text>
					<u-toast ref="uToast"></u-toast>
					<view class="commonButton">
						<u-button type="primary" @click="createCheck">任务创建</u-button>
					</view>
					<u-modal
						:show="visible"
						title="提示"
						content='任务下发终点与规定线体不匹配, 是否继续创建?'
						:showCancelButton="true"
						:closeOnClickOverlay="false"
						@cancel="visible = false"
						@confirm="confirmSubmit"
					></u-modal>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		uniCard
	} from '@dcloudio/uni-ui'
	import { getListAPI, createMissionAPI, searchDescriptionAPI, osusumeStorageAPI, checkRuleAPI } from '@/api/work/wcsStorage'
	import uniDataSelect from '../../../node_modules/@dcloudio/uni-ui/lib/uni-data-select/uni-data-select.vue'
	export default {
		components: {
			uniCard,
			uniDataSelect
		},
		data() {
			return {
				visible: false,
				cardTitle: '',
				// from区域1
				fromOneValue1: '',
				fromOneValue2: '',
				fromOneValue3: '',
				fromOneValue4: '',
				fromOneRange1: [],
				fromOneRange2: [],
				fromOneRange3: [],
				fromOneRange4: [],
				// from区域2
				fromTwoValue1: '',
				fromTwoValue2: '',
				fromTwoValue3: '',
				fromTwoValue4: '',
				fromTwoRange1: [],
				fromTwoRange2: [],
				fromTwoRange3: [],
				fromTwoRange4: [],
				// to区域1
				toOneValue1: '',
				toOneValue2: '',
				toOneValue3: '',
				toOneValue4: '',
				toOneRange1: [],
				toOneRange2: [],
				toOneRange3: [],
				toOneRange4: [],
				// to区域2
				toTwoValue1: '',
				toTwoValue2: '',
				toTwoValue3: '',
				toTwoValue4: '',
				toTwoRange1: [],
				toTwoRange2: [],
				toTwoRange3: [],
				toTwoRange4: [],
				range1: [],
				// 描述1
				description1: '',
				description2: '',
				description3: '',
				description4: '',
				// 可视框
				visible1: false,
				visible2: false,
				visible3: false,
				visible4: false,
				timer1: null,
				timer2: null,
				timer3: null,
				timer4: null
			};
		},
		onUnload() {
			this.clearTimer(this.timer1)
			this.clearTimer(this.timer2)
			this.clearTimer(this.timer3)
			this.clearTimer(this.timer4)
		},
		watch: {
			fromOneValue4(newVal) {
				this.description1 = newVal === '' ? '' : this.description1;
			},
			fromTwoValue4(newVal) {
				this.description2 = newVal === '' ? '' : this.description2;
			},
			toOneValue4(newVal) {
				this.description3 = newVal === '' ? '' : this.description3;
			},
			toTwoValue4(newVal) {
				this.description4 = newVal === '' ? '' : this.description4;
			}
		},
		mounted() {
			this.getList()
		},
		methods: {
			clearTimer(timer) {
				if (timer) {
					clearTimeout(timer)
				}
			},
			resetData() {
				this.fromOneValue1 = '',
				this.fromOneValue2 = '',
				this.fromOneValue3 = '',
				this.fromOneValue4 = '',
				this.fromOneRange1 = [],
				this.fromOneRange2 = [],
				this.fromOneRange3 = [],
				this.fromOneRange4 = [],
				this.fromTwoValue1 = '',
				this.fromTwoValue2 = '',
				this.fromTwoValue3 = '',
				this.fromTwoValue4 = '',
				this.fromTwoRange1 = [],
				this.fromTwoRange2 = [],
				this.fromTwoRange3 = [],
				this.fromTwoRange4 = [],
				this.toOneValue1 = '',
				this.toOneValue2 = '',
				this.toOneValue3 = '',
				this.toOneValue4 = '',
				this.toOneRange1 = [],
				this.toOneRange2 = [],
				this.toOneRange3 = [],
				this.toOneRange4 = [],
				this.toTwoValue1 = '',
				this.toTwoValue2 = '',
				this.toTwoValue3 = '',
				this.toTwoValue4 = '',
				this.toTwoRange1 = [],
				this.toTwoRange2 = [],
				this.toTwoRange3 = [],
				this.toTwoRange4 = [],
				this.range1 = [],
				this.description1 = '',
				this.description2 = '',
				this.description3 = '',
				this.description4 = ''
				this.getList()
			},
			async createCheck() {
				// checkRuleAPI
				const submitForm = {
					fromStorageId1: this.fromOneValue4,
					fromStorageId2: this.fromTwoValue4,
					toStorageId1: this.toOneValue4,
					toStorageId2: this.toTwoValue4
				}
				const res = await checkRuleAPI(submitForm)
				if (res.code === 200) {
					if (res.data === true) {
						// 正确的逻辑
						this.createMission()
					} else {
						// 弹框逻辑
						this.visible = true
					}
				}
			},
			// 弹框confirm
			confirmSubmit() {
				this.createMission()
			},
			async createMission() {
				const submitForm = {
					fromStorageId1: this.fromOneValue4,
					fromStorageId2: this.fromTwoValue4,
					toStorageId1: this.toOneValue4,
					toStorageId2: this.toTwoValue4
				}
				// console.log(submitForm)
				try{
					const res = await createMissionAPI(submitForm)
					if (res.code === 200) {
						this.resetData()
						this.$refs.uToast.show({
							type: 'success',
							message: res.message
						})
					} else {
						return this.$refs.uToast.show({
							type: 'warning',
							message: res.message
						})
					}
				} finally {
					//TODO handle the exception
					this.visible = false
				}
			},
			async getList() {
				const submitForm = {
					storageArea: '',
					storageId: '',
					storageLine: '',
					storagePoint: ''
				}
				const res = await getListAPI(submitForm)
				// console.log(res)
				if (res.code === 200) {
					this.fromOneRange1 = res.data.storageArea.map(item => {
						return {
							text: item,
							value: item
						}
					})
					this.fromTwoRange1 = res.data.storageArea.map(item => {
						return {
							text: item,
							value: item
						}
					})
					this.toOneRange1 = res.data.storageArea.map(item => {
						return {
							text: item,
							value: item
						}
					})
					this.toTwoRange1 = res.data.storageArea.map(item => {
						return {
							text: item,
							value: item
						}
					})
				}
			},
			async fromOneChange(e, index) {
				const submitForm = {
					storageArea: '',
					storageLine: '',
					storagePoint: '',
					storageId: ''
				}
				switch(index) {
					case 1:
						submitForm.storageArea = e
						this.fromOneValue2 = ''
						this.fromOneValue3 = ''
						this.fromOneValue4 = ''
						this.fromOneRange3 = []
						this.fromOneRange4 = []
						this.description1 = ''
						break
					case 2:
						submitForm.storageArea = this.fromOneValue1
						submitForm.storageLine = e
						this.fromOneValue3 = ''
						this.fromOneValue4 = ''
						this.fromOneRange4 = []
						this.description1 = ''
						break
					case 3:
						submitForm.storageArea = this.fromOneValue1
						submitForm.storageLine = this.fromOneValue2
						submitForm.storagePoint = e
						this.fromOneValue4 = ''
						this.fromOneRange4 = []
						this.description1 = ''
						break
					case 4:
						submitForm.storageArea = this.fromOneValue1
						submitForm.storageLine = this.fromOneValue2
						submitForm.storagePoint = this.fromOneValue3
						submitForm.storageId = e
						break
				}
				// console.log(submitForm)
				const res = await getListAPI(submitForm)
				if (res.data.storageDescription) {
				 this.description1 = res.data.storageDescription
				}
				switch(index) {
					case 1:
						this.fromOneRange2 = res.data.storageLine.map(item => {
							return {
								text: item,
								value: item
							}
						})
						break
					case 2:
						this.fromOneRange3 = res.data.storagePoint.map(item => {
							return {
								text: item,
								value: item
							}
						})
						break
					case 3:
						this.fromOneRange4 = res.data.storageId.map(item => {
							return {
								text: item,
								value: item
							}
						})
						break
				}
			},
			async fromTwoChange(e, index) {
				const submitForm = {
					storageArea: '',
					storageLine: '',
					storagePoint: '',
					storageId: ''
				}
				switch(index) {
					case 1:
						submitForm.storageArea = e
						this.fromTwoValue2 = ''
						this.fromTwoValue3 = ''
						this.fromTwoValue4 = ''
						this.fromTwoRange3 = []
						this.fromTwoRange4 = []
						this.description2 = ''
						break
					case 2:
						submitForm.storageArea = this.fromTwoValue1
						submitForm.storageLine = e
						this.fromTwoValue3 = ''
						this.fromTwoValue4 = ''
						this.fromTwoRange4 = []
						this.description2 = ''
						break
					case 3:
						submitForm.storageArea = this.fromTwoValue1
						submitForm.storageLine = this.fromTwoValue2
						submitForm.storagePoint = e
						this.fromTwoValue4 = ''
						this.fromTwoRange4 = []
						this.description2 = ''
						break
					case 4:
						submitForm.storageArea = this.fromTwoValue1
						submitForm.storageLine = this.fromTwoValue2
						submitForm.storagePoint = this.fromTwoValue3
						submitForm.storageId = e
						break
				}
				// console.log(submitForm)
				const res = await getListAPI(submitForm)
				if (res.data.storageDescription) {
				 this.description2 = res.data.storageDescription
				}
				switch(index) {
					case 1:
						this.fromTwoRange2 = res.data.storageLine.map(item => {
							return {
								text: item,
								value: item
							}
						})
						break
					case 2:
						this.fromTwoRange3 = res.data.storagePoint.map(item => {
							return {
								text: item,
								value: item
							}
						})
						break
					case 3:
						this.fromTwoRange4 = res.data.storageId.map(item => {
							return {
								text: item,
								value: item
							}
						})
						break
				}
			},
			async toOneChange(e, index) {
				const submitForm = {
					storageArea: '',
					storageLine: '',
					storagePoint: '',
					storageId: ''
				}
				switch(index) {
					case 1:
						submitForm.storageArea = e
						this.toOneValue2 = ''
						this.toOneValue3 = ''
						this.toOneValue4 = ''
						this.toOneRange3 = []
						this.toOneRange4 = []
						this.description3 = ''
						break
					case 2:
						submitForm.storageArea = this.toOneValue1
						submitForm.storageLine = e
						this.toOneValue3 = ''
						this.toOneValue4 = ''
						this.toOneRange4 = []
						this.description3 = ''
						break
					case 3:
						submitForm.storageArea = this.toOneValue1
						submitForm.storageLine = this.toOneValue2
						submitForm.storagePoint = e
						this.toOneValue4 = ''
						this.toOneRange4 = []
						this.description3 = ''
						break
					case 4:
						submitForm.storageArea = this.toOneValue1
						submitForm.storageLine = this.toOneValue2
						submitForm.storagePoint = this.toOneValue3
						submitForm.storageId = e
						break
				}
				// console.log(submitForm)
				const res = await getListAPI(submitForm)
				if (res.data.storageDescription) {
				 this.description3 = res.data.storageDescription
				}
				switch(index) {
					case 1:
						this.toOneRange2 = res.data.storageLine.map(item => {
							return {
								text: item,
								value: item
							}
						})
						break
					case 2:
						this.toOneRange3 = res.data.storagePoint.map(item => {
							return {
								text: item,
								value: item
							}
						})
						break
					case 3:
						this.toOneRange4 = res.data.storageId.map(item => {
							return {
								text: item,
								value: item
							}
						})
						break
				}
			},
			async toTwoChange(e, index) {
				const submitForm = {
					storageArea: '',
					storageLine: '',
					storagePoint: '',
					storageId: ''
				}
				switch(index) {
					case 1:
						submitForm.storageArea = e
						this.toTwoValue2 = ''
						this.toTwoValue3 = ''
						this.toTwoValue4 = ''
						this.toTwoRange3 = []
						this.toTwoRange4 = []
						this.description4 = ''
						break
					case 2:
						submitForm.storageArea = this.toTwoValue1
						submitForm.storageLine = e
						this.toTwoValue3 = ''
						this.toTwoValue4 = ''
						this.toTwoRange4 = []
						this.description4 = ''
						break
					case 3:
						submitForm.storageArea = this.toTwoValue1
						submitForm.storageLine = this.toTwoValue2
						submitForm.storagePoint = e
						this.toTwoValue4 = ''
						this.toTwoRange4 = []
						this.description4 = ''
						break
					case 4:
						submitForm.storageArea = this.toTwoValue1
						submitForm.storageLine = this.toTwoValue2
						submitForm.storagePoint = this.toTwoValue3
						submitForm.storageId = e
						break
				}
				// console.log(submitForm)
				const res = await getListAPI(submitForm)
				if (res.data.storageDescription) {
				 this.description4 = res.data.storageDescription
				}
				switch(index) {
					case 1:
						this.toTwoRange2 = res.data.storageLine.map(item => {
							return {
								text: item,
								value: item
							}
						})
						break
					case 2:
						this.toTwoRange3 = res.data.storagePoint.map(item => {
							return {
								text: item,
								value: item
							}
						})
						break
					case 3:
						this.toTwoRange4 = res.data.storageId.map(item => {
							return {
								text: item,
								value: item
							}
						})
						break
				}
			},
			async clickItem(key, item) {
				switch(key) {
					case 'from1':
						if (Object.keys(item).length > 0) {
							this.fromOneValue4 = item.value
							this.blurInput('from1')
							this.fromOneChange(item.value, 4)
						}
						break
					case 'from2':
						if (Object.keys(item).length > 0) {
							this.fromTwoValue4 = item.value
							this.blurInput('from2')
							this.fromTwoChange(item.value, 4)
						}
						break
					case 'to1':
						if (Object.keys(item).length > 0) {
							this.toOneValue4 = item.value
							this.blurInput('to1')
							this.toOneChange(item.value, 4)
						}
						return
					case 'to2':
						if (Object.keys(item).length > 0) {
							this.toTwoValue4 = item.value
							this.blurInput('to2')
							this.toTwoChange(item.value, 4)
						}
						return
				}
				const result = await osusumeStorageAPI(item.value)
				if (result.code === 200) {
					// 无敌了
					// console.log(result)
					if (result.data) {
						switch (key) {
							case 'from1':
								this.toOneValue1 = result.data.storageArea
								this.toOneChange(this.toOneValue1, 1)
								this.toOneValue2 = result.data.storageLine
								this.toOneChange(this.toOneValue2, 2)
								this.toOneValue3 = result.data.storagePoint
								this.toOneChange(this.toOneValue3, 3)
								this.toOneValue4 = result.data.storageId
								this.toOneChange(this.toOneValue4, 4)
								break
							case 'from2':
								this.toTwoValue1 = result.data.storageArea
								this.toTwoChange(this.toTwoValue1, 1)
								this.toTwoValue2 = result.data.storageLine
								this.toTwoChange(this.toTwoValue2, 2)
								this.toTwoValue3 = result.data.storagePoint
								this.toTwoChange(this.toTwoValue3, 3)
								this.toTwoValue4 = result.data.storageId
								this.toTwoChange(this.toTwoValue4, 4)
								break
						}
					} else {
						switch (key) {
							case 'from1':
								this.toOneValue1 = ''
								this.toOneValue2 = ''
								this.toOneValue3 = ''
								this.toOneValue4 = ''
								this.toOneRange2 = []
								this.toOneRange3 = []
								this.toOneRange4 = []
								this.description2 = ''
								break
							case 'from2':
								this.toTwoValue1 = ''
								this.toTwoValue2 = ''
								this.toTwoValue3 = ''
								this.toTwoValue4 = ''
								this.toTwoRange2 = []
								this.toTwoRange3 = []
								this.toTwoRange4 = []
								this.description4 = ''
								break
						}
						this.$refs.uToast.show({
							type: 'warning',
							message: '暂无该储位推荐信息'
						})
					}
				}
			},
			blurInput(key) {
				switch(key) {
					case 'from1':
						this.clearTimer(this.timer1)
						this.timer1 = setTimeout(() => {
							this.visible1 = false
						}, 500)
						break
					case 'from2':
						this.clearTimer(this.timer1)
						this.timer2 = setTimeout(() => {
							this.visible2 = false
						}, 500)
						break
					case 'to1':
						this.clearTimer(this.timer1)
						this.timer3 = setTimeout(() => {
							this.visible3 = false
						}, 500)
						break
					case 'to2':
						this.clearTimer(this.timer1)
						this.timer4 = setTimeout(() => {
							this.visible4 = false
						}, 500)
						break
				}
			},
			focusInput(key) {
				switch(key) {
					case 'from1':
						if (this.fromOneRange4.length === 0) {
							return
						} else {
							this.visible1 = true
						}
						break
					case 'from2':
						if (this.fromTwoRange4.length === 0) {
							return
						} else {
							this.visible2 = true
						}
						break
					case 'to1':
						if (this.toOneRange4.length === 0) {
							return
						} else {
							this.visible3 = true
						}
						break
					case 'to2':
						if (this.toOneRange4.length === 0) {
							return
						} else {
							this.visible4 = true
						}
						break
				}
			},
			async confirmInput(key) {
				const submitForm = {
					submitStorage: ''
				}
				// console.log(key)
				switch(key) {
					case 'from1':
						submitForm.submitStorage = this.fromOneValue4
						break
					case 'from2':
						submitForm.submitStorage = this.fromTwoValue4
						break
					case 'to1':
						submitForm.submitStorage = this.toOneValue4
						break
					case 'to2':
						submitForm.submitStorage = this.toTwoValue4
						break
				}
				const res = await searchDescriptionAPI(submitForm.submitStorage)
				// if (res)
				if (res.code === 200) {
					if (res.data) {
						switch(key) {
							case 'from1':
								this.description1 = res.data.storageDescription
								this.fromOneValue1 = res.data.storageArea
								this.fromOneChange(this.fromOneValue1, 1)
								this.fromOneValue2 = res.data.storageLine
								this.fromOneChange(this.fromOneValue2, 2)
								this.fromOneValue3 = res.data.storagePoint
								this.fromOneChange(this.fromOneValue3, 3)
								this.fromOneValue4 = res.data.storageId
								this.fromOneChange(this.fromOneValue4, 4)
								break
							case 'from2':
								this.description2 = res.data.storageDescription
								this.fromTwoValue1 = res.data.storageArea
								this.fromTwoChange(this.fromTwoValue1, 1)
								this.fromTwoValue2 = res.data.storageLine
								this.fromTwoChange(this.fromTwoValue2, 2)
								this.fromTwoValue3 = res.data.storagePoint
								this.fromTwoChange(this.fromTwoValue3, 3)
								this.fromTwoValue4 = res.data.storageId
								this.fromTwoChange(this.fromTwoValue4, 4)
								break
							case 'to1':
								this.description3 = res.data.storageDescription
								return
							case 'to2':
								this.description4 = res.data.storageDescription
								return
							}
						} else {
							switch (key) {
								case 'from1':
									this.fromOneValue1 = ''
									this.fromOneValue2 = ''
									this.fromOneValue3 = ''
									this.fromOneValue4 = ''
									this.fromOneRange2 = []
									this.fromOneRange3 = []
									this.fromOneRange4 = []
									this.description1 = ''
									this.toOneValue1 = ''
									this.toOneValue2 = ''
									this.toOneValue3 = ''
									this.toOneValue4 = ''
									this.toOneRange2 = []
									this.toOneRange3 = []
									this.toOneRange4 = []
									this.description2 = ''
									break
								case 'from2':
									this.fromTwoValue1 = ''
									this.fromTwoValue2 = ''
									this.fromTwoValue3 = ''
									this.fromTwoValue4 = ''
									this.fromTwoRange2 = []
									this.fromTwoRange3 = []
									this.fromTwoRange4 = []
									this.description3 = ''
									this.toTwoValue1 = ''
									this.toTwoValue2 = ''
									this.toTwoValue3 = ''
									this.toTwoValue4 = ''
									this.toTwoRange2 = []
									this.toTwoRange3 = []
									this.toTwoRange4 = []
									this.description4 = ''
									break
							}
							return this.$refs.uToast.show({
								type: 'warning',
								message: '储位号不正确或该储位无信息'
							})
						}
					}
				const result = await osusumeStorageAPI(submitForm.submitStorage)
				if (result.code === 200) {
					// 无敌了
					// console.log(result)
					if (result.data) {
						switch (key) {
							case 'from1':
								this.toOneValue1 = result.data.storageArea
								this.toOneChange(this.toOneValue1, 1)
								this.toOneValue2 = result.data.storageLine
								this.toOneChange(this.toOneValue2, 2)
								this.toOneValue3 = result.data.storagePoint
								this.toOneChange(this.toOneValue3, 3)
								this.toOneValue4 = result.data.storageId
								this.toOneChange(this.toOneValue4, 4)
								break
							case 'from2':
								this.toTwoValue1 = result.data.storageArea
								this.toTwoChange(this.toTwoValue1, 1)
								this.toTwoValue2 = result.data.storageLine
								this.toTwoChange(this.toTwoValue2, 2)
								this.toTwoValue3 = result.data.storagePoint
								this.toTwoChange(this.toTwoValue3, 3)
								this.toTwoValue4 = result.data.storageId
								this.toTwoChange(this.toTwoValue4, 4)
								break
						}
					} else {
						switch (key) {
							case 'from1':
								this.toOneValue1 = ''
								this.toOneValue2 = ''
								this.toOneValue3 = ''
								this.toOneValue4 = ''
								this.toOneRange2 = []
								this.toOneRange3 = []
								this.toOneRange4 = []
								this.description2 = ''
								break
							case 'from2':
								this.toTwoValue1 = ''
								this.toTwoValue2 = ''
								this.toTwoValue3 = ''
								this.toTwoValue4 = ''
								this.toTwoRange2 = []
								this.toTwoRange3 = []
								this.toTwoRange4 = []
								this.description4 = ''
								break
						}
						return this.$refs.uToast.show({
							type: 'warning',
							message: '暂无该储位推荐信息'
						})
					}
				}
			},
			clearInput(val) {
				switch(val) {
					case 1:
						this.fromOneValue1 = ''
						this.fromOneValue2 = ''
						this.fromOneValue3 = ''
						this.fromOneValue4 = ''
						this.fromOneRange2 = []
						this.fromOneRange3 = []
						this.fromOneRange4 = []
						this.description1 = ''
						break
					case 2:
						this.fromTwoValue1 = ''
						this.fromTwoValue2 = ''
						this.fromTwoValue3 = ''
						this.fromTwoValue4 = ''
						this.fromTwoRange2 = []
						this.fromTwoRange3 = []
						this.fromTwoRange4 = []
						this.description2
						break
					case 3:
						this.toOneValue1 = ''
						this.toOneValue2 = ''
						this.toOneValue3 = ''
						this.toOneValue4 = ''
						this.toOneRange2 = []
						this.toOneRange3 = []
						this.toOneRange4 = []
						this.description3 = ''
						break
					case 4:
						this.toTwoValue1 = ''
						this.toTwoValue2 = ''
						this.toTwoValue3 = ''
						this.toTwoValue4 = ''
						this.toTwoRange2 = []
						this.toTwoRange3 = []
						this.toTwoRange4 = []
						this.description4 = ''
						break
				}
			}
		}
	}
</script>

<style lang="scss">
::v-deep uni-view.uni-select {
	padding: 0 !important;
	font-size: 14rpx !important;
}
::v-deep uni-view.uni-select__input-text {
	max-width: 160rpx !important;
}
::v-deep uni-view.uni-select__selector-item {
	font-size: 14rpx !important;
}
::v-deep uni-view.uni-select__selector {
	width: auto !important;
}
::v-deep div.uni-scroll-view-content {
	width: 200rpx !important;
}
::v-deep uni-text.uni-icons.uniui-bottom {
	font-size: 30rpx !important;
}
::v-deep uni-text.uni-icons.uniui-top {
	font-size: 30rpx !important;
}

::v-deep .uni-input-placeholder {
	font-size: 12px;
}

.commonButton {
	width: 100%;
	display: flex;
	gap: 20rpx;
	position: fixed;
	left: 0;
	bottom: 0;
	box-sizing: border-box;
	padding: 15rpx;
	justify-content: space-between;
	background-color: #fff;
	z-index: 999;
}

.people-item {
	height: 70rpx;
	line-height: 70rpx;
	overflow: hidden;
	padding: 0 15rpx;
}

.people-item:hover {
	background-color: #efefef; /* 鼠标悬停时的背景颜色 */
}


::v-deep uni-view.u-input {
	padding: 6px 0 !important;
}

::v-deep div.uni-input-placeholder.input-placeholder {
	color: #6a6a6a !important;
}

::v-deep uni-input.u-input__content__field-wrapper__field {
	font-size: 6px !important;
}

::v-deep uni-view.uni-card.uni-card--shadow.uni-card--border {
	margin: 0 !important;
	padding: 0 !important;
}
::v-deep .uni-card__content {
	color: #000 !important;
}

</style>
